﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AppStore.Domain.Entities;

namespace AppStore.Domain.DAO
{
    public class AppStoreDBInitializer : DropCreateDatabaseIfModelChanges<AppStoreDBConnection>
    {
        protected override void Seed(AppStoreDBConnection context)
        {
            var categories = new List<Category>
                                 {
                                     new Category(){ categoryId = 1, name = "Edukacja"},
                                     new Category(){ categoryId = 2, name = "Finanse"},
                                     new Category(){categoryId = 3,name = "Multimedia"},
                                     new Category(){categoryId = 4,name = "Narzędzia"},
                                     new Category(){categoryId = 5, name = "Sport"},
                                     new Category(){categoryId = 6, name = "Wiadomości"}
                                 };

            categories.ForEach(x => context.Categories.Add(x));

            var applications = new List<Application>
                                   {
                                    new Application()
                                        {
                                            categoryId = 1,
                                            Category = categories.Single(c => c.categoryId == 1),
                                            applicationId = 1,
                                            counter = 2,
                                            name = "Star Chart",
                                            description =
                                                "You can now have a virtual planetarium in your pocket! Look through the eyes of your Android device* to see a virtual window into the whole visible universe.",
                                            price = 10
                                        },new Application()
                                        {
                                            categoryId = 1,
                                            Category = categories.Single(c => c.categoryId == 1),
                                            applicationId = 2,
                                            counter = 2,
                                            name = "Star Chart",
                                            description =
                                                "You can now have a virtual planetarium in your pocket! Look through the eyes of your Android device* to see a virtual window into the whole visible universe.",
                                            price = 10
                                        },new Application()
                                        {
                                            categoryId = 1,
                                            Category = categories.Single(c => c.categoryId == 1),
                                            applicationId = 3,
                                            counter = 2,
                                            name = "Star Chart",
                                            description =
                                                "You can now have a virtual planetarium in your pocket! Look through the eyes of your Android device* to see a virtual window into the whole visible universe.",
                                            price = 10
                                        },new Application()
                                        {
                                            categoryId = 1,
                                            Category = categories.Single(c => c.categoryId == 1),
                                            applicationId = 4,
                                            counter = 2,
                                            name = "Star Chart",
                                            description =
                                                "You can now have a virtual planetarium in your pocket! Look through the eyes of your Android device* to see a virtual window into the whole visible universe.",
                                            price = 10
                                        },new Application()
                                        {
                                            categoryId = 1,
                                            Category = categories.Single(c => c.categoryId == 1),
                                            applicationId = 5,
                                            counter = 2,
                                            name = "Star Chart",
                                            description =
                                                "You can now have a virtual planetarium in your pocket! Look through the eyes of your Android device* to see a virtual window into the whole visible universe.",
                                            price = 10
                                        },
                                       new Application()
                                           {
                                               categoryId = 2,
                                               Category = categories.Single(c => c.categoryId == 2),
                                               applicationId = 2,
                                               counter = 3,
                                               name = "Mój budżet",
                                               description =
                                                   "Wszystkie koszty w jednym miejscu. Mój budżet nie jest typowy. Dzięki tej aplikacji dokładnie widzisz swoje wpływy i wydatki oraz możesz lepiej zarządzać pieniędzmi.",
                                               price = 5
                                           },
                                           new Application()
                                           {
                                               categoryId = 3,
                                               Category = categories.Single(c => c.categoryId == 3),
                                               applicationId = 3,
                                               counter = 10,
                                               name = "MX Player",
                                               description =
                                                   "MX Player - Wyższy poziom oglądania.",
                                               price = 18
                                           }
                                   };

            applications.ForEach(a => context.Applications.Add(a));


        }
    }
}
